package cn.hy.preparelesson.common.utils;

import org.springframework.util.DigestUtils;

import java.io.UnsupportedEncodingException;

/**
 * 密码utils
 */
public class PasswordUtils {

    /**
     * 获取加密后的密码
     * @return
     */
    public static String getPassword(String password, String salt) {
        try {
            return DigestUtils.md5DigestAsHex((password + "xyxxyx" + salt).getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            return "";
        }
    }

    public static void main(String[] args) {
        System.out.println(getPassword("test", "2"));
        System.out.println(getPassword("test", "3"));
        System.out.println(getPassword("test", "4"));
    }

}
